// created on 02.08.2007 at 18:20
using System;

namespace Gamadus.Engine
{
	public struct real
	{
		public double val;
		private real(double val)
		{
			this.val = val;
		}
		//BINARY//
		//binary plus*
		public static real operator +(real x, real y)
		{
			return new real(x.val + y.val);
		}
		//binary minus*
		public static real operator -(real x, real y)
		{
			return new real(x.val - y.val);
		}
		//binary multipliaction*
		public static real operator *(real x, real y)
		{
			return new real(x.val * y.val);
		}
		//binary division*
		public static real operator /(real x, real y)
		{
			return new real(x.val / y.val);
		}
		//binary modulo*
		public static real operator %(real x, real y)
		{
			return new real(x.val % y.val);
		}
		//binary and*
		public static real operator &(real x, real y)
		{
			int ix, iy;
			ix = (int)x.val;
			iy = (int)y.val;
			return new real(ix & iy);
			
		}
		//binary or*
		public static real operator |(real x, real y)
		{
			int ix, iy;
			ix = (int)x.val;
			iy = (int)y.val;
			return new real(ix | iy);
			
		}
		//binary xor*
		public static real operator ^(real x, real y)
		{
			int ix, iy;
			ix = (int)x.val;
			iy = (int)y.val;
			return new real(ix ^ iy);
			
		}
		//binary shift left*
		public static real operator <<(real x, int y)
		{
			int ix;
			ix = (int)x.val;
			return new real(ix << y);
			
		}
		//binary shift right*
		public static real operator >>(real x, int y)
		{
			int ix;
			ix = (int)x.val;
			return new real(ix >> y);
			
		}
		//equal operator*
		public static real operator ==(real x, real y)
		{
			return x.val == y.val ? 1 : 0;
		}
		public static real operator ==(real x, bool y)
		{
			return ((x.val > 0) == y) ? 1 : 0;
		}
		public static real operator ==(bool x, real y)
		{
			return ((y.val > 0) == x) ? 1 : 0;
		}
//		public static real operator ==(real x, object y)
//		{
//			real r = (real) y;
//			return x.val == r.val ? 1 : 0;
//		}
//		public static real operator ==(object x, real y)
//		{
//			real r = (real) x;
//			return y.val == r.val ? 1 : 0;
//		}
		//not equal operator*
		public static real operator !=(real x, real y)
		{
			return x.val != y.val ? 1 : 0;
		}
		public static real operator !=(real x, bool y)
		{
			return ((x.val <= 0) == y) ? 1 : 0;
		}
		public static real operator !=(bool x, real y)
		{
			return ((y.val <= 0) == x) ? 1 : 0;
		}
//		public static real operator !=(real x, object y)
//		{
//			real r = (real) y;
//			return x.val != r.val ? 1 : 0;
//		}
//		public static real operator !=(object x, real y)
//		{
//			real r = (real) x;
//			return y.val != r.val ? 1 : 0;
//		}
		//greater operator*
		public static real operator >(real x, real y)
		{
			return x.val > y.val ? 1 : 0;
		}
//		public static real operator >(real x, object y)
//		{
//			real r = (real) y;
//			return x.val > r.val ? 1 : 0;
//		}
//		public static real operator >(object x, real y)
//		{
//			real r = (real) x;
//			return r.val > y.val ? 1 : 0;
//		}
		//smaller operator*
		public static real operator <(real x, real y)
		{
			return x.val < y.val ? 1 : 0;
		}
//		public static real operator <(real x, object y)
//		{
//			real r = (real) y;
//			return x.val < r.val ? 1 : 0;
//		}
//		public static real operator <(object x, real y)
//		{
//			real r = (real) x;
//			return r.val < y.val ? 1 : 0;
//		}
		//greater/equal operator*
		public static real operator >=(real x, real y)
		{
			return x.val >= y.val ? 1 : 0;
		}
//		public static real operator >=(real x, object y)
//		{
//			real r = (real) y;
//			return x.val >= r.val ? 1 : 0;
//		}
//		public static real operator >=(object x, real y)
//		{
//			real r = (real) x;
//			return r.val >= y.val ? 1 : 0;
//		}
		//smaller/equal operator*
		public static real operator <=(real x, real y)
		{
			return x.val <= y.val ? 1 : 0;
		}
//		public static real operator <=(real x, object y)
//		{
//			real r = (real) y;
//			return x.val <= r.val ? 1 : 0;
//		}
//		public static real operator <=(object x, real y)
//		{
//			real r = (real) x;
//			return r.val <= y.val ? 1 : 0;
//		}
		//UNARY//
		//not*
		public static real operator !(real x)
		{
			return new real((x.val > 0) ? 0 : 1);
		}
		//plus*
		public static real operator +(real x)
		{
			return new real(x.val);
		}
		//minus*
		public static real operator -(real x)
		{
			return new real(-x.val);
		}
		public static bool operator true(real x)
		{
			return (x.val > 0);
		}
		public static bool operator false(real x)
		{
			return (x.val <= 0);
		}
		//conversions and other stuff
		public static implicit operator real(bool x)
		{
			return new real(x ? 1 : 0);
		}
		public static implicit operator real(double x)
		{
			return new real(x);
		}
		public static implicit operator bool(real x)
		{
			return (x.val > 0);
		}
		public static implicit operator double(real x)
		{
			return x.val;
		}
		public static implicit operator int(real x)
		{
			return (int)x.val;
		}
		public override bool Equals(object obj)
		{
			if(obj is real)
				return this.val.Equals(((real)obj).val);
			else
				return false;
		}
		public override string ToString()
		{
			
			return this.val.ToString(System.Globalization.CultureInfo.InvariantCulture);
		}
		public override int GetHashCode()
		{
			return this.val.GetHashCode();
		}

	}
}